import http from '@/utils/http'

interface BasicParams {
  dtoName: string // 参考后端接口文档
  queryId: string // 参考confluence上的页面需求SQL标识
  version: string // 参考confluence上的页面需求SQL版本号
  menuName: string // 菜单的标识，与菜单管理配置保持一致
  usage: string // 接口后缀，标识用途
  params: string
}

/*
  eg./ims-tworkgz-service/viewCstHistory/getCstHistory
*/

/** 获取 getOwner 信息 */
export function getOwner(data: BasicParams, method: any = 'GET'): Promise<any> {
  const { menuName, usage, params } = data
  return http.request({
    url: `/ims-tworkgz-service/${menuName}/${usage}`,
    method,
    params
  })
}
/** 获取 createGlass 信息 */
export function createGlass(data: BasicParams): Promise<any> {
  const { params } = data
  return http.request({
    url: '/ims-tworkgz-service/createGlass',
    method: 'POST',
    data: params
  })
}

/** 获取 exportExcel 信息 */
export function exportExcel(data: BasicParams): Promise<any> {
  return http.request({
    url: '/ims-tworkgz-service/createGlass/export',
    method: 'POST',
    responseType: 'blob',
    data
  })
}
/** 获取 getProductId 信息 */
export function getProductId(data: BasicParams, method: any = 'GET'): Promise<any> {
  const { menuName, usage, params } = data
  return http.request({
    url: `/ims-tworkgz-service/${menuName}/${usage}`,
    method,
    params
  })
}
